// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store

const api = {
  /**
     * 获取结算单数据
     */
  getCostStatementController(params) {
    return Service.get(
      `/${ServiceName}/api/external/CostStatementController/queryall`, { params }
    )
  },
  /**
     * 根据id查询总计表
     */
  getDataListById(id) {
    return Service.get(
      `/${ServiceName}/api/external/CostStatementController/querybyid?id=${id}`
    )
  },
  /**
     * 根据收费方，付费方批量销账
     */
  getDataListQueryBy(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/CostStatementController/queryby?payCompanyName=${params.payCompanyName}&chargeCompanyName=${params.chargeCompanyName}`
    )
  },
  /**
     * 销账点击确定
     */
  dataListInsert(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/CostStatementController/insert`,params
    )
  },
  /**
   * 查询发票
   */
  getInvoiceData(id) {
    return Service.get(
      `/${ServiceName}/api/external/CostStatementController/queryAllKp?id=${id}`
    )
  },
  /**
   * 增加发票
   */
  addInvoiceData(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/CostStatementController/insertkp`,params
    )
  },
  /**
   * 根据id查询发票
   */
  getInvoiceById(id) {
    return Service.get(
      `/${ServiceName}/api/external/CostStatementController/queryByIdKp?id=${id}`
    )
  },
  /**
   * 删除发票
   */
  deleteInvoiceData(params) {
    return Service.post(
      `/${ServiceName}/api/external/CostStatementController/deleteByIdKp`,params
    )
  },
  /**
   * 修改发票
   */
  changeInvoiceData(params) {
    store.commit('changeStatus', true)
    return Service.put(
      `/${ServiceName}/api/external/CostStatementController/updateKp`,params
    )
  },
  /**
   * 统计月份
   */
  changeMonth(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/CostStatementController/insertMonth`,params
    )
  },
  /**
   * 根据id获取账期table
   */
  getPostpone(statementId) {
    return Service.get(
      `/${ServiceName}/api/external/CostStatementController/queryStatementId?statementId=${statementId}`
    )
  },
   /**
   * 根据延期id查附件
   */
   getPostponeById(id) {
    return Service.get(
      `/${ServiceName}/api/external/CostStatementController/queryId?id=${id}`
    )
  },
  /**
   * 新增账期
   */
  addPostpone(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/CostStatementController/insertPostpone`,params
    )
  },
  /**
   * 删除账期
   */
  deletePostpone(params) {
    return Service.post(
      `/${ServiceName}/api/external/CostStatementController/deleteId`,params
    )
  }
}
export default api
